package com.edu.hre.common.crontab;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.edu.hre.common.utils.BeanFinder;

/**
 * Servlet implementation class CallTaskServlet
 */
public class CallTaskServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CallTaskServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String action = request.getParameter("act");
		if("mail".equalsIgnoreCase(action)){
			NotifyEMailBirthday bean = BeanFinder.getBean(NotifyEMailBirthday.BEAN_NAME, NotifyEMailBirthday.class);
			bean.run();
		} else {
			response.getWriter().write("Not found parameter 'act'");
			return;
		}
		response.getWriter().write("OK");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
